<%@ tag language="java" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/commons/taglib.jsp"%>
<%@ attribute name="id" type="java.lang.String" required="true" description="编号"%>
<%@ attribute name="name" type="java.lang.String" required="true" description="隐藏域名称（ID）"%>
<%@ attribute name="value" type="java.lang.String" required="true" description="隐藏域值（ID）"%>
<%@ attribute name="labelName" type="java.lang.String" required="true" description="输入框名称（Name）"%>
<%@ attribute name="labelValue" type="java.lang.String" required="true" description="输入框值（Name）"%>
<%@ attribute name="jsonRoot" type="java.lang.String" required="false" description="数据路径"%>
<%@ attribute name="parentIdKey" type="java.lang.String" required="false" description="选择框标题"%>
<%@ attribute name="title" type="java.lang.String" required="true" description="选择框标题"%>
<%@ attribute name="url" type="java.lang.String" required="true" description="树结构数据地址"%>
<%@ attribute name="checked" type="java.lang.Boolean" required="false" description="是否显示复选框，如果不需要返回父节点，请设置notAllowSelectParent为true"%>
<%@ attribute name="extId" type="java.lang.String" required="false" description="排除掉的编号（不能选择的编号）"%>
<%@ attribute name="isAll" type="java.lang.Boolean" required="false" description="是否列出全部数据，设置true则不进行数据权限过滤（目前仅对dept有效）"%>
<%@ attribute name="notAllowSelectRoot" type="java.lang.Boolean" required="false" description="不允许选择根节点"%>
<%@ attribute name="notAllowSelectParent" type="java.lang.Boolean" required="false" description="不允许选择父节点"%>
<%@ attribute name="allowClear" type="java.lang.Boolean" required="false" description="是否允许清除"%>
<%@ attribute name="allowInput" type="java.lang.Boolean" required="false" description="文本框可填写"%>
<%@ attribute name="cssClass" type="java.lang.String" required="false" description="css样式"%>
<%@ attribute name="cssStyle" type="java.lang.String" required="false" description="css样式"%>
<%@ attribute name="smallBtn" type="java.lang.Boolean" required="false" description="缩小按钮显示"%>
<%@ attribute name="hideBtn" type="java.lang.Boolean" required="false" description="是否显示按钮"%>
<%@ attribute name="disabled" type="java.lang.String" required="false" description="是否限制选择，如果限制，设置为disabled"%>
<%@ attribute name="dataMsgRequired" type="java.lang.String" required="false" description=""%>
<style rel='stylesheet'>
.dropdown-menu-right {
    right: 0;
    left: auto;
}
.input-group .readonly{
cursor: pointer;
}
.input-group.disabled .readonly{
cursor: not-allowed;
}
.input-group.disabled a{
cursor: not-allowed;
}
</style>

<div class="input-group ${disabled}" id="${id}TreeLayer">
	<input id="${id}Id" name="${name}" class="${cssClass}" type="hidden" value="${value}"/>
	<input id="${id}Name" name="${labelName}" ${allowInput?'':'readonly="readonly"'} type="text" value="${labelValue}" data-msg-required="${dataMsgRequired}" class="form-control ${cssClass} ${allowInput?'':'readonly'}" style="${cssStyle}"/>
	<span class="input-group-btn">
		<a id="${id}Button" href="javascript:"  class="btn btn-primary btn-sm dropdown-toggle  ${disabled} ${hideBtn ? 'hide' : ''}" ${disabled}> <span class="caret"></span></a>
	 
	</span>
	<div class='panel panel-default dropdrownpanel' style='width:100%;max-height:600px;max-width:100%;display:none;position: absolute;z-index:99999'>
          <sys:tree id="${id }" url="${url }" jsonRoot="${jsonRoot }" parentIdKey="${parentIdKey }"></sys:tree>
        </div>
	</div>

<script type="text/javascript">
		$("#${id}Button,#${id}Name").click(function(e){
			if ($("#${id}Button").hasClass("disabled")){
				return true;
			}
			$('.dropdrownpanel').fadeOut("fast");//关闭其他下拉框
			var dropdownpanel = $(this).parents('.input-group').find('.dropdrownpanel');
			var relObject = $(this).parents('.input-group');
			dropdownpanel.css({left:"0px", top:relObject.position().top + relObject.outerHeight() + "px"}).slideDown("fast");
			e.stopPropagation();
		});
		$("body").click(function(){
			$('#${id}TreeLayer  .dropdrownpanel').fadeOut("fast");
		});
		$('#${id}TreeLayer  .dropdrownpanel').click(function(e){
			e.stopPropagation();
		});
		${id}TreeSelectCallBack = function(event, treeId, treeNode){
			console.info(treeNode.name);
			$("#${id}Id").val(treeNode.id);
			$("#${id}Name").val(treeNode.name);
		}
</script>